<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>转优车流程附加信息页面</title>
    <jsp:include page="../../import.jsp" flush="true" />
    <jsp:include page="../assDealCar/assDealCarFunc.jsp" flush="true" /><!-- 重构后的js方法 -->
    <jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <!-- 页签1：-->
            <div tabid="tabA" title="拖车单信息" lselected="true">
                <form id="optimalCar_view">
                    <c:if test="${'1' == flag || '2' == flag || '3' == flag || '4' == flag}">
                        <div class="disp_up disp_right">
                            <span>
                                <c:if test="${light >= 4 && light <= 8}">
                                    <font color="blue"><i class="ico_flasher_blue"></i>资料上传剩余<7天</font>
                                </c:if>
                                <c:if test="${light > 0 && light <= 3}">
                                    <font color="red"><i class="ico_flasher"></i>资料上传剩余<3天</font>
                                </c:if>
                            </span>
                        </div>
                    </c:if>
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="fieldBox col_50">
                            <div class="label">申请人</div>
                            <div class="field">
                                <span id="applyNm" name="applyNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">申请时间</div>
                            <div class="field">
                                <span id="applyDt" name="applyDt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 基本信息 -->
                        <div class="caption">
                            <span class="title">基本信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">承租人</div>
                            <div class="field">
                                <span id="cstNm" name="cstNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">合同编号</div>
                            <div class="field">
                                <span id="contNo" name="contNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">支付表号</div>
                            <div class="field">
                                <span id="paySchNo" name="paySchNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">经销商</div>
                            <div class="field">
                                <span id="splNm" name="splNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">事业部</div>
                            <div class="field">
                                <span id="orgName" name="orgName">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">业务负责人</div>
                            <div class="field" style="width: 100%;">
                                <span id="cstMgrNm" name="cstMgrNm">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 设备信息 -->
                        <div class="caption">
                            <span class="title">设备信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="detailGrid">
                                    <!-- 设备信息列表显示块 -->
                                    <div id="ligergrid_equ" class="sq-grid"></div>
                                </div>
                            </div>
                        </div>
                        <!-- 逾期信息 -->
                        <div class="caption">
                            <span class="title">逾期信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">租赁周期</div>
                            <div class="field">
                                <span id="lsPd" name="lsPd">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">已还租金(元)</div>
                            <div class="field">
                                <span id="actualAmt" name="actualAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">逾期租金(元)</div>
                            <div class="field">
                                <span id="overdueAmt" name="overdueAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">逾期天数</div>
                            <div class="field">
                                <span id="overdueDay" name="overdueDay">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">罚息金额(元)</div>
                            <div class="field">
                                <span id="penaltyAmt" name="penaltyAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">应还款金额(元)</div>
                            <div class="field">
                                <span id="payAmt" name="payAmt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 拖车信息 -->
                        <div class="caption">
                            <span class="title">拖车信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">拖车原因</div>
                            <div class="field">
                                <span id="backReason" name="backReason">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 附件显示 -->
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <jsp:include page="../assCommFilesList.jsp" flush="true" ></jsp:include>
                                <div id="ligergrid_file1" class="sq-grid"></div>
                            </div>
                        </div>
                        <!-- 可编辑信息 -->
                        <div class="fieldBox col_33">
                            <div class="label">拖车单位名称</div>
                            <div class="field">
                                <span id="companyNm" name="companyNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">预计拖回时间</div>
                            <div class="field">
                                <span id="backDt" name="backDt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拖回保管城市</div>
                            <div class="field">
                                <span id="provinceCity" name="provinceCity">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">停车场名称</div>
                            <div class="field">
                                <span id="parkNm" name="parkNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_66">
                            <div class="label">停车场地址</div>
                            <div class="field">
                                <span id="parkAddress" name="parkAddress">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">优车资产管理员</div>
                            <div class="field">
                                <span id="assMgs" name="assMgs">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拖车费用(元/辆)</div>
                            <div class="field">
                                <span id="backPrice" name="backPrice">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拖车数量</div>
                            <div class="field">
                                <span id="backQty" name="backQty" >&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">拖车费合计(元)</div>
                            <div class="field">
                                <span id="backAmt" name="backAmt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 收款信息 -->
                        <div class="caption">
                            <span class="title">收款信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">收款方名称</div>
                            <div class="field">
                                <span id="payeeAccNm" name="payeeAccNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">开户银行</div>
                            <div class="field">
                                <span id="payeeBankNm" name="payeeBankNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">开户行行号</div>
                            <div class="field">
                                <span id="payeeBankNo" name="payeeBankNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">银行账号</div>
                            <div class="field">
                                <span id="payeeAccNo" name="payeeAccNo">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">实际拖回时间</div>
                            <div class="field">
                                <span id="actBackDt" name="actBackDt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label"></div>
                            <div class="field"></div>
                        </div>
                        <!-- 付款信息 -->
                        <div class="caption fkxx">
                            <span class="title">付款信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">付款方名称</div>
                            <div class="field">
                                <span name="payerAccNm" id="payerAccNm">&nbsp;狮桥融资租赁（中国）有限公司</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">开户银行</div>
                            <div class="field">
                                <span name="payerBankNm" id="payerBankNm">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">银行账号</div>
                            <div class="field">
                                <span name="payerAccNo" id="payerAccNo">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 未来本金等值,实际明细 -->
                        <div class="fieldBox col_33">
                            <div class="label">未来本金(元)</div>
                            <div class="field">
                                <span name="futureAmt" id="futureAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">逾期租金(元)</div>
                            <div class="field">
                                <span name="overRentAmt" id="overRentAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">履约保证金(元)</div>
                            <div class="field">
                                <span name="performanceAmt" id="performanceAmt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 保险保证金等值,实际明细 -->
                        <div class="fieldBox col_33">
                            <div class="label">保险保证金(元)</div>
                            <div class="field">
                                <span name="insureAmt" id="insureAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">其他费用(元)</div>
                            <div class="field">
                                <span name="otherAmt" id="otherAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">风险保证金(元)</div>
                            <div class="field">
                                <span name="riskAmt" id="riskAmt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 实际付款时间等值,实际明细 -->
                        <div class="fieldBox col_33">
                            <div class="label">实际付款时间</div>
                            <div class="field">
                                <span id="actPayDt" name="actPayDt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">实际付款金额(元)</div>
                            <div class="field">
                                <span id="actPayAmt" name="actPayAmt">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">保底价款(元)</div>
                            <div class="field">
                                <span name="baseAmt" id="baseAmt">&nbsp;</span>
                            </div>
                        </div>
                        <!-- 车辆交接单 -->
                        <div class="fieldBox col_33 tcjjd">
                            <div class="label">车辆交接单</div>
                            <div class="field">
                                <%--<c:if test="${flag == '2' }"><!-- 发起人节点 -->--%>
                                <%--<a class="modify1" href="javascript:void(0);" onclick="entryOrder('modify1')">修改</a>--%>
                                <%--</c:if>--%>
                                <%--<c:if test="${flag == '4' }"><!-- 系统管理员补充交接单节点 -->--%>
                                <%--<a class="modify2" href="javascript:void(0);" onclick="entryOrder('modify2')">修改</a>--%>
                                <%--</c:if>--%>
                                <a class="detail" href="javascript:void(0);" onclick="entryOrder('detail')">查看</a>
                            </div>
                        </div>
                        <div class="fieldBox col_66 tcjjd">
                            <div class="field">
                                <a href="javascript:void(0);" onclick="exportAssCarHvPdf()">导出</a>
                            </div>
                        </div>

                        <!-- 借款信息holly START-->
                        <div class="caption">
                            <span class="title">借款信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="detailGrid">
                                    <!-- 借款信息列表显示块 -->
                                    <div id="ligergrid_fin" class="sq-grid"></div>
                                </div>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label  requiredSymbol"  >剩余未核销金额合计(元)</div>
                            <div class="field col_50"  >
                                <span id="arAmts" name="arAmts"> </span>
                            </div>
                        </div>
                        <!-- 借款信息holly END-->


                        <!-- 经营贷信息 -->
                        <div class="caption">
                            <span class="title">经营贷信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="detailGrid">
                                    <!-- 经营贷信息列表显示块 -->
                                    <div id="ligergrid_loan" class="sq-grid"></div>
                                </div>
                            </div>
                        </div>
                        <!-- LNG专项信息 -->
                        <div class="caption">
                            <span class="title">LNG专项信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="detailGrid">
                                    <!-- LNG专项信息列表显示块 -->
                                    <div id="ligergrid_lng" class="sq-grid"></div>
                                </div>
                            </div>
                        </div>
                        <!-- 保险贷信息 -->
                        <div class="caption">
                            <span class="title">保险贷信息</span>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="sqPanel">
                                <div id="detailGrid">
                                    <!-- 保险贷信息列表显示块 -->
                                    <div id="ligergrid_ins" class="sq-grid"></div>
                                </div>
                            </div>
                        </div>
                        <!-- 含小额贷保底价格合计 -->
                        <div class="fieldBox col_33 edit_payer">
                            <div class="label">含小额贷保底价格合计</div>
                            <div class="field">
                                <input name="baseAllAmt" id="baseAllAmt" value="" type="text" class="ui-textbox" validate="{number:true}">
                            </div>
                        </div>
                        <!-- 转优车资料  -->
                        <div class="caption">
                            <span class="title">转优车</span>
                        </div>
                        <!-- 转优车说明 -->
                        <div class="fieldBox col_100 edit_fqr">
                            <div class="label">转优车说明</div>
                            <div class="field">
                                <textarea name="dealDesc" id="dealDesc" rows="3" class="l-textarea" style="width:98%" value="" ></textarea>
                            </div>
                        </div>
                        <div class="fieldBox col_100 show_fqr">
                            <div class="label">转优车说明</div>
                            <div class="field">
                                <span name="dealDesc_1" id="dealDesc_1">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_100 edit_upload">
                            <div class="label">附件上传</div>
                            <div class="field">
                                <jsp:include page="../assCommFilesUpload.jsp" flush="true" >
                                    <jsp:param name="filePath" value="ass"/>
                                </jsp:include>
                                <div id="fileUpload1" class="upfileBoxs"></div>
                                <span class="sq-button sq-button-hasicon" id="btnUpload1" onclick="ajaxFileUploadImg('uploads1',2)">
										<i class="sqBtnIco_9"></i>上传
									</span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div style="width: 98%; margin-left: 1%;">
                                <div id="ligergrid_file2" class="sq-grid"></div>
                            </div>
                        </div>
                        <!-- 盈亏核算  -->
                        <div class="caption">
                            <span class="title">盈亏核算</span>
                        </div>
                        <div class="fieldBox col_33 edit_cwhs">
                            <div class="label">亏损%</div>
                            <div class="field">
                                <input type="text" id="gainLoassScale" name="gainLoassScale" class="ui-textbox" ligerui="width: 160" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33 show_cwhs">
                            <div class="label">亏损%</div>
                            <div class="field">
                                <span name="gainLoassScale_1" id="gainLoassScale_1">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 edit_cwhs">
                            <div class="label">转优车保底价(元)</div>
                            <div class="field">
                                <input type="text" id="dealBaseAmt" name="dealBaseAmt" class="ui-textbox" ligerui="width: 160" value="">
                            </div>
                        </div>
                        <div class="fieldBox col_33 show_cwhs">
                            <div class="label">转优车保底价(元)</div>
                            <div class="field">
                                <span name="dealBaseAmt_1" id="dealBaseAmt_1">&nbsp;</span>
                            </div>
                        </div>
                        <%--<div class="fieldBox col_33 edit_cwhs">--%>
                            <%--<div class="label">转优车时间</div>--%>
                            <%--<div class="field">--%>
                                <%--<input type="text" id="dealTm" name="dealTm" class="ui-datepicker" ligerui="width: 160" value="">--%>
                            <%--</div>--%>
                        <%--</div>--%>
                        <div class="fieldBox col_33 show_cwhs">
                            <div class="label">转优车时间</div>
                            <div class="field">
                                <span name="dealTm_1" id="dealTm_1">&nbsp;</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33 isAssign">
                            <div class="label">是否可过户<font color="red">*</font></div>
                            <div class="field">
                                <select name="isAssign" id="isAssign" class="isAssign">
                                    <option value="  " selected>请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33 isDiffPlace">
                            <div class="label">是否异地提档<font color="red">*</font></div>
                            <div class="field">
                                <select name="isDiffPlace" id="isDiffPlace" class="ui-textbox">
                                    <option value="  " selected>请选择</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33 assManager">
                            <div class="label">资产管理员</div>
                            <div class="field">
                                <input type="text" id="assManager" name="assManager" ligerui="width: 160" value="" placeholder="请选择" ltype="combobox">
                            </div>
                        </div>
                        <div class="caption">
                            <span class="title">维护过户方案</span>
                        </div>
                        <div class="fieldBox col_33 assAccTyp">
                            <div class="label">提户情况<font color="red">*</font></div>
                            <div class="field">
                                <select name="assAccTyp" id="assAccTyp" class="ui-textbox">
                                    <option value="  ">-请选择-</option>
                                    <option value="1">公户</option>
                                    <option value="0">私户</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33 assignAmt">
                            <div class="label">过户费(元)<font color="red">*</font></div>
                            <div class="field">
                                <input type="text" id="assignAmt" name="assignAmt" class="ui-textbox" ligerui="width: 160" value="">
                            </div>
                        </div>
                        <div class="fieldset1 tabel_col clearFix assProFileGrid">
                            <div class="sqPanel_body">
                                <div id="assProFileGrid" class="sq-grid"></div>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">备注</div>
                            <div class="field">
                                <textarea name="remark" id="remark" rows="4" class="ui-textarea l-textarea" style="width:100%" value="">
                                </textarea>
                            </div>
                        </div>
                        <jsp:include page="../assDealCar/assDealCarExtView.jsp" flush="true" />
                        <div class="fieldset1 tabel_col clearFix Hide loanFlowGrid">
                            <div class="sqPanel_body">
                                <div id="loanFlowGrid" class="sq-grid"></div>
                            </div>
                        </div>
                        <!-- 隐藏支付表主键、支付表号 -->
                        <div class="fieldBox col_100" style="display:none;">
                            <div class="field">
                                <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="${tcMasterId}">
                                <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="${tcDetailId}">
                                <input name="tcInfoId" id="tcInfoId" type="text" class="ui-textbox" value="${tcInfoId }">
                                <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjPrdId}">
                                <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="${paySchId}">
                                <input name="wsPaySchId" id="wsPaySchId" type="text" class="ui-textbox" value="${wsPaySchId}">
                                <input name="wsPaySchNo" id="wsPaySchNo" type="text" class="ui-textbox" value="${wsPaySchNo}">
                                <input name="paySchNo" id="paySchNo2" type="text" class="ui-textbox" value="${paySchNo}">
                                <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
                                <input name="buOrgCd" id="buOrgCd" type="text" class="ui-textbox" value="${buOrgCd}">
                                <input name="optimal_Id" id="optimal_Id" type="text" class="ui-textbox" value="${optimal_Id}">
                                <input name="flag" id="flag" type="text" class="ui-textbox" value="${flag }">
                                <!-- 上传文件使用：系统时间和当前登录人姓名 -->
                                <input name="sysDate" id="sysDate" type="text" class="ui-textbox" value="${sysDate }">
                                <input name="loginUsrNm" id="loginUsrNm" type="text" class="ui-textbox" value="${loginUsrNm }">
                            </div>
                        </div>
                    </div>

                    <div class="btnsBox">
                        <span id="updateAssOptimalBtn" class="sq-button sq-button-round updateAssOptimalBtn" onclick="updateAssOptimal()">保存</span>
                    </div>
                </form>
            </div>
            <!-- 页签2：过户信息 -->
            <c:if test="${'5' == flag || '6' == flag || '7' == flag}">
                <div tabid="tabB" title="过户信息">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
            </c:if>
        </div>
    </div>
</div>

<script>
    var assProFileGrid = null;
    var loanFlowGrid = null;
    var id = $("#optimal_Id").val();
    var flag = $("#flag").val();
    var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
    $(function() {
        if ("5" == flag || "6" == flag || "7" == flag) {
            initTab();
        }
        initForm();//初始化表单
        initData();//初始化数据
        initDataDealCar();//初始化转优车数据
        initData_loan();
        loadFilesLiger("tcsq", 1, $("#tcMasterId").val());//加载拖车申请文件列表信息
        loadFilesLiger("zycsq", 2, $("#optimal_Id").val());//加载转优车申请文件列表信息
        initAll_Money();//初始化保底价价+经营贷+lng贷+保险贷
        getMgUsrList();
        // initAssProFileGrid();
        //加载借款信息
        initGrid_fin();
        showOrEdit();//显示还是编辑
    });

    //初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
                switch (tabid){
                    case "tabA":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/ass/assTrailCarD/toOptimalViewPage.do?optimal_Id=" + id + "&flag=" + flag);
                        break;
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/ass/dealcar/manage/toTransInfoInFlow.do?dealId=" + id + "&flag=" + flag);
                        break;
                }
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }

    //获取优车资产管理员
    function getMgUsrList(){
        $("#assManager").ligerComboBox({
            url: "<%=path%>/ass/assParking/searchManagerList.do?flag=1",
            ajaxType :'GET',
            valueField: "key",
            textField: "value",
            autocomplete: function (e){
                filter_autoComboboxData(e.key, this);
                e.show();
            },
            keySupport: true,
        });
    }

    // 通过提户情况判断上传哪些资料项
    $("#assAccTyp").change(function(){
        var assAccTyp = $("#assAccTyp").val();
        initAssProFileGrid(assAccTyp);
        assProFileGrid.reload();
    });

    // 维护过户方案资料Grid
    function initAssProFileGrid(assAccTyp) {
        assProFileGrid = $("#assProFileGrid").ligerGrid({
            url: '<%=path%>/ass/assTrailCarD/initAssProFileGrid.do?id=' + id + '&assAccTyp=' + assAccTyp,
            method: 'get',
            columns: [
                {display: '资料名称', name: 'datNm', align: 'center', minWidth: 100, enabledSort: false},
                {
                    display: '上传文件名称', name: 'fileNm', minWidth: 100, enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        if (value) {
                            var h;
                            h = '<a href="javascript:uploadFileByUrl(';
                            h += "'" + rowdata.filePath + "'";
                            h += ",'" + rowdata.fileNm + "'";
                            h += ')">' + rowdata.fileNm + '</a>'
                            return h;
                        }
                    }
                },
                {
                    display: '上传时间',
                    name: 'crtTm',
                    align: 'center',
                    width: 150,
                    enabledSort: false,
                    render: renderDate
                },
                {display: '上传用户', name: 'upUsrNm', width: 100, enabledSort: false},
                {
                    display: '操作', name: 'operate', minWidth: 100, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        if ('1' == flag) {
                            var h = '';
                            h += '<a class="sq-button-hasicon uploadFile" style="cursor:pointer;" onclick="uploadFile(\'' + rowdata.cfgCd + '\', \'' + rowdata.cfgDtlCd + '\')"><i class="sqBtnIco_9"></i>上传</a><span class="sq-button sq-button-round fileupload-button" style="display: none;">上传<input type="file" id="uploadInput_' + rowdata.cfgCd + '_' + rowdata.cfgDtlCd + '" multiple name="fileup_' + rowdata.cfgCd + '_' + rowdata.cfgDtlCd + '"' +
                                ' class="fileupload-input" onchange="onChangefile_multi(event,\'' + rowdata.cfgCd + '\',\'' + rowdata.cfgDtlCd + '\',\'' + rowdata.orgCd + '\');"></span>';
                            if ('' != rowdata.fileId && null != rowdata.fileId) {
                                h += '<a class="sq-button-hasicon delFile" id="delFile_' + rowdata.cfgDtlCd + '" style="cursor:pointer;" onclick="delFile(event,' + rowdata.fileId + ');"><i class="sqBtnIco_7"></i>删除</a>';
                            }
                            return h;
                        }
                    }
                }
            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: '200px',
            isScroll: false,
            rownumbers: true,  //显示序号
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            frozen: false,
            usePager: false,
            onAfterShowData: function () {
                $('#assProFileGrid').rowspan('datNm');
                $('#assProFileGrid').rowspan('operate');
            },
        });
    }

    // 上传文件a标签链接到input标签上
    function uploadFile(cfgCd, cfgDtlCd) {
        document.getElementById("uploadInput_" + cfgCd + "_" + cfgDtlCd).click();
    }

    //初始化保底价价+经营贷+lng贷+保险贷
    function initAll_Money(){
        var tcMasterId = $("#tcMasterId").val();
        var paySchId = $("#paySchId").val();
        if(!tcMasterId){
            $.ligerDialog.SQalert({content: "拖车申请主表ID为空,无法查询相关信息！",SQ_type: "error"});
            return;
        }

        //加载拖车主表信息
        var _url = '<%=path%>/ass/assTrailCarFlowInfo/getAllMoney.do';

        $.ajax({
            type: 'get',
            dataType:'json',
            data:{tcMasterId:tcMasterId,paySchId:paySchId},
            url: _url,
            success:function(msg){
                if(msg.success == 1){
                    var data=msg.data;
                    $("#baseAllAmt").val(data.baseAmt / 100);//设置数据
                }else{
                    // alert(msg.success);
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }
    //初始化表单
    function initForm(){
        $("#optimalCar_view").ligerForm({
            validate: true
        });
        $("#optimalCar_view").check_ligerFormEditor();//重新刷新页面动态字段
    };
    //初始化数据经营贷信息-LNG专项信息
    function initData_loan(){
        var tcMasterId = $("#tcMasterId").val();
        if(!tcMasterId){
            $.ligerDialog.SQalert({content: "拖车申请主表ID为空,无法查询相关信息！",SQ_type: "error"});
            return;
        }
        //经营贷信息
        initGrid_loan(tcMasterId);
        //LNG专项信息
        initGrid_lng(tcMasterId);
        //保险信息
        initGrid_ins(tcMasterId);
    }
    //初始化列表
    function initGrid_ins(id){

        $("#ligergrid_ins").ligerGrid({
            url:'<%=path%>/ass/assTrailCarFlowInfo/getInsPayInfo.do',
            method:'get',
            parms:{tcMasterId:id,loanType:1},
            columns:[
                { display: '贷款合同号', name: 'contNo', minWidth: 160, enabledSort:true},
                { display: '贷款类型', name: 'loanType', minWidth: 150 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(rowdata.loanType=='1'){
                            h = '分期还款';
                        }
                        if(rowdata.loanType=='2'){
                            h = '全款';
                        }
                        return h;
                    }


                },

                { display: '实际贷款金额(元)', name: 'insTotalAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.insTotalAmt / 100;
                        return anyString(h);
                    }

                },
                { display: '已还本金合计(元)', name: 'totCapAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还利息合计(元)', name: 'totIntrAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还罚息合计(元)', name: 'totdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余本金合计(元)', name: 'overplusCapAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余利息合计(元)', name: 'overplusIntrAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余罚息合计(元)', name: 'overplusdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '逾期租金合计(元)', name: 'overdueAmount', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overdueAmount / 100;
                        return anyString(h);
                    }
                },
                { display: '经营贷应收结清款(元)', name: 'clearAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.clearAmt / 100;
                        return anyString(h);
                    }
                }
            ],
            usePager: false,//是否有分页便签
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            isScroll: false,//是否有滚动条
            checkbox: false, //列表是否有选择框
            rownumbers:true//列表是否有行号
        });
        grid = liger.get("ligergrid_ins");
        grid.options.isSingleCheck = true;//列表是否为单选
    }
    //初始化列表
    function initGrid_loan(id){

        $("#ligergrid_loan").ligerGrid({
            url:'<%=path%>/ass/assTrailCarFlowInfo/getMcrBillInfo.do',
            method:'get',
            parms:{tcMasterId:id,loanType:1},
            columns:[
                { display: '贷款合同号', name: 'crCntNo', minWidth: 160, enabledSort:true},
                { display: '贷款类型', name: 'crTypCd', minWidth: 150 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(rowdata.crTypCd=='FQHK'){
                            h = '分期还款';
                        }
                        if(rowdata.crTypCd=='SJSH'){
                            h = '随借随还';
                        }
                        return h;
                    }

                },


                { display: '实际贷款金额(元)', name: 'actCrAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.actCrAmt / 100;
                        return anyString(h);
                    }

                },
                { display: '已还本金合计(元)', name: 'totCapAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还利息合计(元)', name: 'totIntrAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还罚息合计(元)', name: 'totdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余本金合计(元)', name: 'overplusCapAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余利息合计(元)', name: 'overplusIntrAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余罚息合计(元)', name: 'overplusdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '逾期租金合计(元)', name: 'overdueAmount', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "0";
                        h = rowdata.overdueAmount / 100;
                        return anyString(h);
                    }
                },
                { display: '经营贷应收结清款(元)', name: 'clearAmt', width: 100, enabledSort:true,

                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.clearAmt / 100;
                        return anyString(h);
                    }
                }
            ],
            // enabledEdit: true,
            usePager: false,//是否有分页便签
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            isScroll: false,//是否有滚动条
            checkbox: false, //列表是否有选择框
            rownumbers:true//列表是否有行号
        });
        grid = liger.get("ligergrid_loan");
        grid.options.isSingleCheck = true;//列表是否为单选
    }
    //初始化列表
    function initGrid_lng(id){

        $("#ligergrid_lng").ligerGrid({
            url:'<%=path%>/ass/assTrailCarFlowInfo/getMcrBillInfo.do',
            method:'get',
            parms:{tcMasterId:id,loanType:2},
            columns:[
                { display: '贷款合同号', name: 'crCntNo', minWidth: 160, enabledSort:true},
                { display: '贷款类型', name: 'crTypCd', minWidth: 150 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(rowdata.crTypCd=='FQHK'){
                            h = '分期还款';
                        }
                        if(rowdata.crTypCd=='SJSH'){
                            h = '随借随还';
                        }
                        return h;
                    }

                },


                { display: '实际贷款金额(元)', name: 'actCrAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.actCrAmt / 100;
                        return anyString(h);
                    }

                },
                { display: '已还本金合计(元)', name: 'totCapAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还利息合计(元)', name: 'totIntrAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '已还罚息合计(元)', name: 'totdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.totdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余本金合计(元)', name: 'overplusCapAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusCapAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余利息合计(元)', name: 'overplusIntrAmt', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusIntrAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '剩余罚息合计(元)', name: 'overplusdefaultAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.overplusdefaultAmt / 100;
                        return anyString(h);
                    }
                },
                { display: '逾期租金合计(元)', name: 'overdueAmount', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "0";
                        h = rowdata.overdueAmount / 100;
                        return anyString(h);
                    }
                },
                { display: 'LNG应收结清款(元)', name: 'clearAmt', width: 100, enabledSort:true,

                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.clearAmt / 100;
                        return anyString(h);
                    }
                }
            ],
            usePager: false,//是否有分页便签
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            isScroll: false,//是否有滚动条
            checkbox: false, //列表是否有选择框
            rownumbers:true//列表是否有行号
        });
        grid = liger.get("ligergrid_lng");
        grid.options.isSingleCheck = true;//列表是否为单选
    }
    //初始化数据
    function initData(){
        var tcMasterId = $("#tcMasterId").val();
        if(!tcMasterId){
            $.ligerDialog.SQalert({content: "拖车申请主表ID为空,无法查询相关信息！",SQ_type: "error"});
            return;
        }
        var wait_dialog= $.ligerDialog.SQalert({
            content: LogUtils.LOG_CMM_LOADING,
            SQ_type: "waitting",
            onClose: function () {
            }
        });
        //加载设备信息
        initGrid_equ(tcMasterId);
        //加载拖车主表信息
        var _url = '<%=path%>/ass/assTrailCarM/getTrailCarMaster.do';
        $.ajax({
            type: 'get',
            dataType:'json',
            data:{tcMasterId:tcMasterId},
            url: _url,
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    setData(msg.data);//设置数据
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }
    /* HOLLY START*/
    //初始化借款信息
    function initGrid_fin( ){
        var paySchId = $("#wsPaySchId").val();
        $("#ligergrid_fin").ligerGrid({
            parms:{paySchId:paySchId},
            url: '<%=path%>/finpayschfee/finance/getPaySchFeeList.do',
            method : 'get',
            columns:[
                { display: '序号', name: 'feeRem', width: 40 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        return rowindex+1;
                    }},
                { display: '借款类型', name: 'feeTypCdNm', width: 150, enabledSort:true },
                { display: '借款金额(元)', name: 'feeAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
                        return value/100;
                    } },
                { display: '实付金额(元)', name: 'feeAmt', width: 150 , enabledSort:true,render:function (rowdata, rowindex, value, column){
                        return value/100;
                    }},
                { display: '已核销金额(元)', name: 'paidUpAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
                        return value/100;
                    }},
                { display: '实付时间', name: 'crtTm', width: 200, enabledSort:true,render: function (rowdata, rowindex, value, column) {
                        var dateStr = "";
                        if(null != value){
                            var date = new Date(value);
                            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
                        }
                        return dateStr;
                    }},
                { display: '付款单号', name: 'feeRem', width: 200, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h ="";
                        if( rowdata.pNo != null){
                            h+='<a class="sq-button-hasicon" href="javascript:commShowFlow(';
                            h+="'"+rowdata.pinstId+"'";
                            h+=",'"+rowdata.audStsCd+"'";
                            h+=",'"+rowdata.dataId+"'";
                            h+=",'"+rowdata.formUrl+"'";
                            h+=")\"><i class='sqBtnIco_32'></i>"+rowdata.pNo+"</a>";
                        }
                        return h;
                    }},
                { display: '备注', name: 'feeRem', width: 200, enabledSort:true }
            ],
            onAfterShowData :function (e){
                var rows=e.rows;
                var i=0;
                for ( var index in rows) {
                    i+=rows[index].arAmt;
                }
                $("#arAmts").text(i/100+" 元");
            },
            usePager: false,//是否有分页便签
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            height:'100%',
            heightDiff:-2,
            isScroll: false,//是否有滚动条
            checkbox:false,//列表是否有选择框
            rownumbers:false//列表是否有行号
        });
    }
    //显示流程：流程实例ID,状态,业务主键(拖车主表ID)
    function commShowFlow(_pInstId, _audStsCd, _businessKey,_formUrl){
        if(StringUtils.isEmpty(_pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
        Add_navTab('tab_ass_trail_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }

    /* HOLLY END*/
    //设置页面数据
    function setData(data){
        //显示申请信息
        $("#applyNm").html(data.applyNm);
        $("#applyDt").html(renderDate1(data.applyDt));
        $("#backReason").html(data.backReason);
        //设置用来显示的元素值
        $("#companyNm").html(data.companyNm);
        $("#backDt").html(renderDate1(data.backDt));
        $("#backPrice").html(data.backPrice / 100);
        $("#backQty").html(data.backQty);
        $("#backAmt").html(data.backAmt / 100);
        $("#payeeAccNm").html(data.payeeAccNm);
        $("#payeeBankNm").html(data.payeeBankNm);
        $("#payeeBankNo").html(data.payeeBankNo);
        $("#payeeAccNo").html(data.payeeAccNo);
        //显示拖回保管城市等信息
        $("#parkNm").html(data.parkNm);
        $("#assMgs").html(data.assManagers);
        $("#parkAddress").html(data.parkAddress);
        $("#provinceCity").html(data.provinceCity);
        //显示付款信息
        $("#payerBankNm").html(data.payerBankNm);
        $("#payerAccNo").html(data.payerAccNo);
    }
    //初始化转优车数据
    function initDataDealCar(){
        var id = $("#optimal_Id").val();
        if(!id){
            $.ligerDialog.SQalert({content: "处置-转优车信息表ID为空,无法查询相关信息！",SQ_type: "error"});
            return;
        }
        var wait_dialog= $.ligerDialog.SQalert({
            content: LogUtils.LOG_CMM_LOADING,
            SQ_type: "waitting",
            onClose: function () {
            }
        });
        //加载拖车主表信息
        var _url = '<%=path%>/ass/assTrailCarD/getDealCarById.do';
        $.ajax({
            type: 'get',
            dataType:'json',
            data:{id:id},
            url: _url,
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    setDataDealCar(msg.data);//设置数据
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }
    //设置页面数据
    function setDataDealCar(data){
        $("#dealDesc").val(data.dealDesc);
        $("#dealDesc_1").html(data.dealDesc);
        $("#dealBaseAmt").val(data.dealBaseAmt / 100);
        $("#dealBaseAmt_1").html(data.dealBaseAmt / 100);
        // $("#dealTm").val(renderDate1(data.dealTm));
        $("#dealTm_1").html(renderDate1(data.dealTm));
        liger.get("isAssign").setValue(data.isAssign);
        liger.get("isDiffPlace").setValue(data.isDiffPlace);
        $("#assignAmt").val(data.feeAmt / 100);
        var accList = [{"key":"1", "value":"公户"}, {"key":"0", "value":"私户"}];
        $.each(accList, function (i, o) {
            if (data.assAccTyp == o.key) {
                $("#assAccTyp").val(o.key);
                $("#assAccTyp_txt_val").val(o.key);
                $("#assAccTyp_txt").val(o.value);
                $("#assAccTyp").selected = true;
                initAssProFileGrid(data.assAccTyp);
                assProFileGrid.reload();
            }
        });
        $("#recipientName").val(data.recipientName);
        liger.get("receiveType").setValue(data.receiveType);
        $("#contactNumber").val(data.contactNumber);
        $("#express").val(data.express);
        $("#expressNumber").val(data.expressNumber);
        if ('[]' != data.manageNm) {
            $("#assManager").val(data.manageNm);
        }
        if ('' != data.manageId && null != data.manageId) {
            $("#assManager_val").val(data.manageId);
        }
        $("#remark").val(data.remark);
    }
    //初始化列表
    function initGrid_equ(id){
        var flag = $("#flag").val();
        $("#ligergrid_equ").ligerGrid({
            url:'<%=path%>/ass/assTrailCarM/getTrailCarDetail.do',
            method:'get',
            parms:{tcMasterId:id},
            columns:[
                { display: '租赁物名称', name: 'prdNm', minWidth: 160, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = rowdata.prdNm;
                        initPkData(rowdata);//设置主键值及主要信息
                        return h;
                    }},
                { display: '型号', name: 'prdMdl', minWidth: 150 , enabledSort:true},
                { display: '是否新车', name: 'isNew', width: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '否';
                        if(rowdata.isNew==1){
                            h = '是';
                        }
                        return h;
                    }},
                { display: '<font color="red">GPS是否在线</font>', name: 'isOnline', width: 120, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        var online = '';
                        h+='<select id="isOnline" name="isOnline">';
                        h+='<option value="0" ';
                        if(rowdata.isOnline==0){
                            h+='selected';
                            online = '否';
                        }
                        h+='>否</option>';
                        h+='<option value="1" ';
                        if(rowdata.isOnline==1){
                            h+='selected';
                            online = '是';
                        }
                        h+='>是</option></select>';
                        //判断是否为显示
                        if(flag!="2"){
                            h = online;
                        }
                        return h;
                    }},
                { display: '使用期限(月)', name: 'usedPd', width: 100 , enabledSort:true},
                { display: '单价', name: 'guidePc', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.guidePc / 100;
                        return h;
                    }},
                { display: '数量', name: 'prdQty', width: 100, enabledSort:true},
                { display: '留购价', name: 'rsrvPc', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = 0;
                        h = rowdata.rsrvPc / 100;
                        return h;
                    }},
                //{ display: '买卖合同编号', name: 'salContNo', width: 100 , enabledSort:true},
                { display: '车辆配置单', name: 'overdueAmt', width: 100, enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        h+='<a href="javascript:showOp(';
                        h+="'"+rowdata.prjId+"'";
                        h+=",'"+rowdata.prjPrdId+"'";
                        h+=")\">查看</a>";
                        return h;
                    }}
            ],
            usePager: false,//是否有分页便签
            root:'rows',
            record:'total',
            hideLoadButton:false,
            width:'100%',
            isScroll: false,//是否有滚动条
            checkbox:false,//列表是否有选择框
            rownumbers:true//列表是否有行号
        });
        grid = liger.get("ligergrid_equ");
        grid.options.isSingleCheck = true;//列表是否为单选
    }

    //设置关键字的值-各表主键
    function initPkData(rowdata){
        //加载表单
        var form = liger.get("optimalCar_view");
        var tcDetailId = $("#tcDetailId").val();
        if(!tcDetailId){//为空执行
            form.setData({
                tcDetailId: rowdata.id,//拖车明细表ID
            });
        }
        form.setData({
            tcInfoId: rowdata.infoId,//拖车实际明细表ID
            paySchId: rowdata.paySchId
        });
        //设置支付表可查看
        var paySchNo='<a href="javascript:payDetail(';
        paySchNo+="'"+rowdata.prjPrdDtlId+"',"; //项目产品明细信息表ID
        paySchNo+="'"+rowdata.paySchId+"',"; //支付表ID
        paySchNo+="'"+rowdata.prjPrdId+"',"; //项目产品基础信息表ID
        paySchNo+="'"+rowdata.prjId+"'"; //项目基础信息表ID
        paySchNo+=')">'+rowdata.paySchNo+'</a>';
        //设置基本信息显示
        $("#cstNm").html(rowdata.cstNm);
        $("#contNo").html(rowdata.contNo);
        $("#paySchNo").html(paySchNo);
        $("#paySchNo2").val(rowdata.paySchNo);
        $("#splNm").html(rowdata.splNm);
        $("#orgName").html(rowdata.orgName);
        $("#cstMgrNm").html(rowdata.cstMgrNm);
        //设置逾期信息
        $("#lsPd").html(rowdata.lsPd);
        $("#actualAmt").html(rowdata.actualAmt / 100);
        $("#overdueAmt").html(rowdata.overdueAmt / 100);
        $("#overdueDay").html(rowdata.overdueDay);
        $("#penaltyAmt").html(rowdata.penaltyAmt / 100);
        $("#payAmt").html(rowdata.payAmt / 100);
        $("#gainLoassScale_1").html(rowdata.gainLoassScale);
        $("#gainLoassScale").val(rowdata.gainLoassScale);
        //初始化实际明细信息
        initDInfoData();
        initBindFinLoanFLow();
    }

    // 关联借款流程
    function initBindFinLoanFLow() {
        var paySchNo = $("#wsPaySchNo").val();
        // paySchNo = '';
        loanFlowGrid = $("#loanFlowGrid").ligerGrid({
            url: '<%=path%>/finance/finLoanInfo/initLoanPayList.do?paySchNo=' + paySchNo,
            method: 'get',
            columns: [
                {display: '费用项', name: 'loanTypCd', align: 'center', minWidth: 100, enabledSort: false},
                {display: '实付金额', name: 'feeAmt', align: 'center', width: 80, enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.feeAmt / 100);
                    }
                },
                {display: '待还款金额', name: 'arAmt', align: 'center', width: 250, enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.arAmt / 100);
                    }
                },
                {display: '流程编号', name: 'pno', minWidth: 100, enabledSort: false,
                    render: function (rowdata, rowindex, value, column) {
                        if(StringUtils.isEmpty(value)){
                            value = "";
                        }
                        var h = '';
                        h='<a href="javascript:showFlow(';
                        h+="'"+rowdata.pinstId+"',";
                        h+="'"+rowdata.audStsCd+"',";
                        h+="'"+rowdata.dataId+"',";
                        h+="'"+rowdata.formUrl+"'";
                        h+=')">'+value+'</a>'
                        return h;
                    }
                }
            ],
            root: 'rows',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            isScroll: false,
            rownumbers: true,  //显示序号
            checkbox: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            frozen: false,
            usePager: false,
        });
    }

    //到流程跟踪页
    function showFlow(pInstId,audStsCd,dataId,formUrl){
        if(StringUtils.isEmpty(pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var params = "?pInsId="+pInstId+"&status="+audStsCd+"&businessKey="+dataId+"&formUrl="+formUrl;
        Add_navTab('finloaninfo'+pInstId,'查看流程',"/web/flow/flow/toFlowShowPageFowBus.do"+params);
    }

    //初始化拖车实际明细表数据
    function initDInfoData(){
        var tcInfoId = $("#tcInfoId").val();
        if(!tcInfoId){
            //$.ligerDialog.SQalert({content: "拖车实际明细表ID为空,无法查询相关信息！",SQ_type: "error"});
            return;
        }else{
            var wait_dialog= $.ligerDialog.SQalert({
                content: LogUtils.LOG_CMM_LOADING,
                SQ_type: "waitting",
                onClose: function () {
                }
            });
            //加载拖车实际明细信息
            var _url = '<%=path%>/ass/assTrailCarDInf/getById.do';
            $.ajax({
                type: 'get',
                dataType:'json',
                data:{tcInfoId:tcInfoId},
                url: _url,
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        setDInfData(msg.data);//设置数据
                    }else{
                        $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                    }
                }
            });
        }
    }

    //设置拖车实际明细信息
    function setDInfData(data){
        $("#futureAmt").html(data.futureAmt / 100);
        $("#overRentAmt").html(data.overRentAmt / 100);
        $("#performanceAmt").html(data.performanceAmt / 100);
        $("#insureAmt").html(data.insureAmt / 100);
        $("#riskAmt").html(data.riskAmt / 100);
        $("#otherAmt").html(data.otherAmt / 100);
        $("#baseAmt").html(data.baseAmt / 100);
        $("#actPayDt").html(renderDate1(data.actPayDt));
        $("#actPayAmt").html(data.actPayAmt / 100);
        $("#actBackDt").html(renderDate1(data.actBackDt));
    }

    //查看支付表详情
    function payDetail(prjPrdDtlId,id,prjPrdId,prjId){
        var editFlag = true;
        Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
    }
    //保存文件-获取对应上传组件的文件列表
    function saveFile(){
        var index = 2;//转优车申请附件
        var eflag = "zycsq";
        var docArray = JSON.stringify(getUploadResultParams(index));
        var url = "<%=path%>/ass/assTrailCarD/uploadAttchment.do";
        var optimal_Id = $("#optimal_Id").val();
        if(null == docArray){
            return false;
        }else{
            if(optimal_Id){//拖车主表ID不为空执行
                //赋值附件
                var data = {
                    "docArray":docArray,
                    "pkId":optimal_Id,
                    "flag": eflag
                };
                //请求
                AjaxUtils.ajaxPost(url, data, function(msg){
                    if(msg.success == 1){
                        if(msg.data){
                            //刷新附件页面GRID方法和清空上传按钮
                            refreshUlFileRecList(index);
                            clearUploadResultParams(index);
                        }
                    }else{
                        UIUtils.alertError(msg.info);
                    }
                }, true);
            }else{
                $.ligerDialog.SQalert({content: "业务主键为空-不能保存文件！",SQ_type: "error"});
            }
        }
    }

    //显示已上传但是未保存的文件列表
    function showFiles(data, index){
        var sysDate = $("#sysDate").val();
        var loginUsrNm = $("#loginUsrNm").val();
        var f_Grid = liger.get("ligergrid_file"+index);
        var uploadJOSN = data;
        for (var i=0; i< uploadJOSN.length; i++){
            //添加行-追加行
            f_Grid.addRow({fileNm: uploadJOSN[i].fileNm, crtUsrRlNm: loginUsrNm, crtTm: sysDate, doSthFlag: "1", ligerIndex: index,id:i});
        }
    }

    // 保存或修改数据
    function updateAssOptimal() {
        var ligerForm = liger.get("optimalCar_view");
        // validateBeforeUpdate();
        var flag = $("#flag").val();
        if ('1' == flag) {
            // 过户资料上传
            var isPass = null;
            var msg = null;
            $.ajax({
                type: 'get',
                async: false,
                cache: false,
                url: "<%=path%>/ass/assTrailCarD/initAssProFileGrid.do?assAccTyp=" + assAccTyp + "&id=" + id + "&validate=1",
                success: function (data) {
                    isPass = data.split('_')[0].replace('"', '');
                    msg = data.split('_')[1].replace('"', '');
                }
            });
            if ('0' == isPass) {
                top.$.ligerDialog.SQalert({content: "请上传" + msg, SQ_type: "error"});
                return false;
            }
        }
        if("1" == flag || "2" == flag || '3' == flag || '4' == flag || '6' == flag ||"7" == flag){
            //获取表单数据
            var data = ligerForm.getData();
            var assManager = $("#assManager_val").val();
            data["assManager"] = assManager;
            // console.log(data);
            var wait_dialog = null;
            var url = '<%=path%>/ass/assTrailCarD/updateOptimalInfo.do';
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: url,
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        saveFile();//保存文件
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                    }else{
                        top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                    }
                }
            });
        }
        if(flag == '4'){//库管管理员补充车辆交接单
            saveFile();//保存文件
        }
    }

    //取消/关闭当前页签
    function closeBtn(){
        var TAB=top.mainApp.parentTab;
        var currentTabid=TAB.getSelectedTabItemID();
        top.tab.removeTabItem(currentTabid);
    }



    /**
     * 上传文件
     * @param e
     * @param cfgCd
     * @param cfgDtlCd
     * @param orgCd
     */
    function onChangefile_multi(e, cfgCd, cfgDtlCd, orgCd) {
        var wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
        var filePath = "";
        filePath = "assProFile";

        $.ajaxFileUpload({
            url: '<%=path%>/system/sysulfilesrec/upload.do',
            secureuri: false,
            fileElementId: e.target.id,  //这里不在是以前的id了，要写成数组的形式！
            dataType: 'json',
            data: {filePath: filePath},
            success: function (msg) {
                if (msg.success == 1) {
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: {
                            'fileParams': JSON.stringify(msg.data),
                            'id': id,
                            'cfgCd': cfgCd,
                            'cfgDtlCd': cfgDtlCd,
                            'orgCd': orgCd
                        },
                        url: '<%=path%>/ass/assTrailCarD/uploadAssProFile.do',
                        success: function (msg) {
                            if (msg.success == 1) {
                                assProFileGrid.get
                                assProFileGrid.reload();
                            } else {
                                $.ligerDialog.SQalert({content: "资料上传超时", SQ_type: "error"});
                            }
                            $.ligerDialog.hide();
                        }
                    });
                } else {
                    wait_dialog.close();
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    };

    // 删除文件
    function delFile(event, _fileId) {
        top.$.ligerDialog.confirm("确认删除吗?", function (flag) {
            if (!flag) {
                return;
            } else {
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {'fileId': _fileId},
                    url: '<%=path%>/project/prjFileInfo/removeFile.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        if (msg.success == 1) {
                            wait_dialog.close();
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            parent.$('li[tabid="mateTab"] a').text('项目资料(' + msg.data + ')');
                            event.stopPropagation();
                            var gridID = $(event.target).parents('.sq-grid').attr('ligeruiid');
                            liger.get(gridID).reload();
                        } else {
                            wait_dialog.close();
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            }
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    //入库交接单
    function entryOrder(crflag){
        var tcMasterId = $("#tcMasterId").val();//拖车主表ID
        var tcDetailId = $("#tcDetailId").val();//拖车明细ID
        var paySchId = $("#wsPaySchId").val();//支付表ID
        var paySchNo = $("#wsPaySchNo").val();//支付表号
        var prjId = $("#prjId").val();//项目ID
        var param = '&&tcMasterId='+tcMasterId+'&&tcDetailId='+tcDetailId+'&&crflag='+crflag;
        param += '&&paySchId='+paySchId+'&&paySchNo='+paySchNo+'&&prjId='+prjId;
        Add_navTab('entryOrder'+tcDetailId,'车辆交接单','<%=path%>/ass/assTrailCarM/toWarehousePage.do?' + param);
    }

    //导出车辆交接单PDF
    function exportAssCarHvPdf(){
        var tcDetailId = $("#tcDetailId").val();//拖车明细ID
        window.location.href='<%=path%>/ass/assTrailCarD/exportAssCarHvPdf.do?tcDetailId='+tcDetailId;
    }

    //车辆配置单
    function showOp(_prjId,_prjPrdId){
        Add_navTab("corePrcBook"+_prjPrdId, "车辆配置单", '<%=path%>/audit/audStandingBook/toCorePrcBookAddPage.do?prjPrdId='+_prjPrdId+'&proIntId='+$("#proIntId").val()+'&projectId='+_prjId+'&isDetail='+1);
    }
</script>
</body>
</html>